<style>
.bzss{ width:100%; height:auto; margin:15px auto;}
.bzss p{ text-align:center; font-size:18px; line-height:36px;}
.bzss p span{color:#FB0509; border:1px solid #777777; border-radius:5px; padding:0px 15px; cursor:pointer;}
.bzss table{ width:100%; height:auto; text-align:center;}
.bzss table tr td{ border:1px solid #ccc; font-size:18px; line-height:26px;}
.bzss table tr{ height:40px;}
.bzss table tr td input{background: #43A1DA;cursor: pointer;color: #FFF;width: 80px;height: 30px;margin: 5px 5px 5px 0;border: 1px solid #4ba6db;border-radius: 5px;}
.bzss form{ width:300px; margin:15px auto; text-align:right; display:none;}
.bzss form input{ width:194px; height:52px; margin-bottom:10px; margin-left:20px; text-indent:1.5em; font-size:16px;}
.bzss form select{ width:194px; height:52px; margin-bottom:10px; margin-left:20px;}
.bzss form span{color:red; font-size:18px; line-height:30px;}
.bzss form input#sumit{background: #43A1DA;cursor: pointer;color: #FFF;width: 128px;height: 30px;margin: 5px 38px 5px 0;border: 1px solid #4ba6db;border-radius: 5px;}
.num{ color:#777777; text-decoration:none; cursor:pointer;}
.num:hover{ color:#0089e1;}
.current{ color:#0089e1; cursor:pointer;}
.next{ color:#777777; text-decoration:none;}
.prev{color:#777777; text-decoration:none;}
</style>
<div class="bzss">
	<p>病种类型设置：<span class="new">新增</span></p>
    <table cellpadding="0" cellspacing="0">
    	<tr>
        	<td width="10%"><input type="button" value="全选" class="qx"/></td>
            <td width="10%"><input type="button" value="反选" class="fx"/></td>
            <td width="15%"><input type="button" value="删除所选" class="alldelete"/></td>
            <td width="20%"></td>
            <td width="25%">共{$count}条</td>
            <td width="20%">{$page}</td>
        </tr>
        <tr></tr>
        <tr>
        	<td>选择</td>
            <td>排序</td>
            <td>名称</td>
            <td>增加时间</td>
            <td>修改时间</td>
            <td>操作</td>
        </tr>
        <volist id="vo" name="list">
        <tr>
        	<td><input type="checkbox" name="{$vo.bzname}"/></td>
            <td>{$vo.sort}</td>
            <td align="left"><option value="{$vo.level}" style="float:left; width:0; height:0;">{$vo.bzname}</option></td>
            <td>{$vo.addtime}</td>
            <td>{$vo.updatetime}</td>
            <td><input type="button" value="修改" class="update"/>| <input type="button" value="删除" class="delete"/></td>
        </tr>
        </volist>
    </table>
    <form method="post" >
    	<span></span><br/>
        上级栏目：<select>
        			<option value="0">=====顶级栏目=====</option>
                    <volist id="vo" name="list">
                    <option value="{$vo.level}" >--{$vo.bzname}</option>
                    </volist>
        		</select>
    	名称:<input type="text" maxlength="5" name="bzname"/><br/>
        排序：<input type="text" maxlength="3" name="sort"/><br/>
                <input type="button" name="sumit" value="提交" id="sumit" style="text-indent:0;"/>
                <input type="hidden" name="type" id="type" />
    </form>
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery/jquery.cookie.js"></script>
<script>
$(function(){
	$("form select option").each(function() {
        var length=$(this).val().split(",").length;
		var jl=length*20+'px';
		$(this).css("text-indent",jl);
    });
	$("table tr td option").each(function() {
        var length=$(this).val().split(",").length;
		var jl=length*10+'px';
		$(this).css("text-indent",jl);
    });
	$(".qx").click(function(){
		$("table input:checkbox").attr("checked",true);	
	});
	$(".fx").click(function(){
		$("table input:checkbox").attr("checked",false);	
	});
	$(".new").click(function(){
		$("table").slideUp(100);
		$("form").slideDown(2000);
	});	
	$("#sumit").click(function(){
		var bzname=$("input[name='bzname']").val();
		var px=$("input[name='sort']").val();
		var type = $("#type").val();
		var lm=$("select option:selected").val().split(",");
		var lm1=$("select option:selected").val().split(",");
		var pid;
		if(lm==0){
			lm1[1]=px;	
			pid=lm[1];
		}else{
			pid=lm[1];	
		}
		var arr = [];
		arr.push(lm,px);
		level=arr.join(",");
		if(bzname!=""&&px!=""){
			$.ajax({
				type:'POST',
				url:"__URL__/bzzsadd",
				data:{bzname:bzname,sort1:px,type:type,level:level,pid:lm1[1]},
				success: function(data){
					$("form").find("span").html("病种已生成！！！");	
					setTimeout(function(){
						$("table").slideDown(2000);
						$("form").slideUp(100);
						window.location.reload();
					},1000);
				}	
			});
		}else{
			$("form").find("span").html("不能有空项！！！");
		}	
	});
	$(".delete").click(function(){
		var bzname=$(this).parent().prev("td").prev("td").prev("td").children().html();
		alert(bzname);
		$.ajax({
			type:'POST',
			url:"__URL__/bzssdelete",
			data:{bzname:bzname},
			success: function(data){
				window.location.reload();
			}
		});
	});
	$(".alldelete").click(function(){
		var valArr = new Array; 
		$("table input:checked:checked").each(function(i) {
		   valArr[i]=$(this).attr("name");
        });
	   var vals = valArr.join(',');
		$.ajax({
			type:'POST',
			url:"__URL__/allbzdelete",
			data:{bzname:vals},
			success: function(data){
				window.location.reload();
			}
		});
	});
	$(".update").click(function(){
		$(".bzss table").fadeOut(100);
		$(".bzss form").fadeIn(2000);
		var bzname=$(this).parent().prev("td").prev("td").prev("td").children().html();
		var sort1=$(this).parent().prev("td").prev("td").prev("td").prev("td").html();
		$("input[name='bzname']").val(bzname);
		$("input[name='sort']").val(sort1);
		$.ajax({
			type:'POST',
			url:"__URL__/bzssupdate",
			data:{bzname:bzname},
			success: function(data){
				$("#type").val(data['type']);
			}
		});
	});
	var bzgl=$.cookie('bzgl');
	bzgl=bzgl.split(",");
	if(bzgl[1]!=1){
		$(".update").attr("disabled", true);
	}
	if(bzgl[2]!=2){
		$(".new").hide();
	}
	if(bzgl[3]!=3){
		$(".delete").attr("disabled", true);
		$(".alldelete").attr("disabled", true);
	}
});
</script>